//
//  MenuButton.swift
//  MenuButton
//
//  Created by sheng on 2017/11/10.
//  Copyright © 2017年 sheng. All rights reserved.
//

import UIKit


class MenuButton: UIButton {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setTitleColor(UIColor.black, for: UIControlState.normal)
        titleLabel?.font = UIFont.systemFont(ofSize: 14)
        titleLabel?.textAlignment = .center
        imageView?.contentMode = .scaleAspectFit
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func imageRect(forContentRect contentRect: CGRect) -> CGRect {
        let imageWidth  = contentRect.size.width
        let imegeHeight = contentRect.size.height * 0.6
        return CGRect(x: 0, y: 0, width: imageWidth, height: imegeHeight)
    }
    
    
    override func titleRect(forContentRect contentRect: CGRect) -> CGRect {
        let titleY      = contentRect.size.height * 0.4
        let titleWidth  = contentRect.size.width
        let titleHeight = contentRect.size.height - titleY
        return  CGRect(x: 0, y: titleY, width: titleWidth, height: titleHeight)
    }
    
    
    //         let button:MenuButton = MenuButton(frame: CGRect(x: 20, y: 60, width: 80, height: 82))
    //         button.setTitle("Current Job", for:UIControlState.normal)
    //         button.setImage(UIImage(named:"page"),for:.normal)
    //         self.view.addSubview(button)
    
}
